#define  _CRT_SECURE_NO_WARNINGS 1
#include <string>
#include<iostream>
using namespace std;
string s;
long long ret = 0;
bool vis[10000000];
void dfs(int x, int pos)
{
    if (x == 4)
    {
        ret++;
        return;
    }
    if (pos == s.size())
        return;
    if (vis[pos] == false)
    {
        if ((x == 0 && s[pos] == '2') || (x == 1 && s[pos] == '0') || (x == 2 && s[pos] == '2') || (x == 3 && s[pos] == '3'))
        {
            vis[pos] = true;
            dfs(x + 1, pos+1);
            vis[pos] = false;
        }
    }
    dfs(x, pos+1);
}
int main()
{

    for (int i = 1; i <= 2023; i++)
    {

        s += to_string(i);
    }
    dfs(0, 0);
    cout << ret << endl;
    return 0;
}